package com.eightbears.beboy.adapter;

import android.text.TextUtils;
import android.view.View;
import android.widget.ImageView;
import android.widget.TextView;

import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.BaseViewHolder;
import com.eightbears.beboy.R;
import com.eightbears.beboy.base.util.CommonUtils;
import com.eightbears.beboy.entity.SearchUser;

public class SearchAdapter extends BaseQuickAdapter<SearchUser.DataBean, BaseViewHolder> {

    private String buttonName;

    public SearchAdapter() {
        super(R.layout.item_user_info, null);
    }

    @Override
    protected void convert(BaseViewHolder baseViewHolder, SearchUser.DataBean searchUser) {
        baseViewHolder.getView(R.id.add_friend).setVisibility(View.VISIBLE);
        TextView add_friend = baseViewHolder.getView(R.id.add_friend);
        if(!TextUtils.isEmpty(buttonName)) {
            add_friend.setText(buttonName);
        }
        CommonUtils.loadImageView(mContext, searchUser.getCover(), R.mipmap.default_head, (ImageView) baseViewHolder.getView(R.id.iv_img_car));
        baseViewHolder.setText(R.id.tv_car_name, searchUser.getNickname())
            .addOnClickListener(R.id.ll_item)
            .addOnClickListener(R.id.add_friend);
    }

    public void putEventBtnName (String name){
        buttonName = name;
    }

}
